Tutorial by Examples: comp

Autoboxing can come at a substantial memory overhead. For example: Map<Integer, Integer> square = new HashMap<Integer, Integer>(); for(int i = 256; i < 1024; i++) { square.put(i, i * i); // Autoboxing of large integers } will typically consume substantial amount of memory (...
Directives can be used to build reusable components. Here is an example of a "user box" component: userBox.js angular.module('simpleDirective', []).directive('userBox', function() { return { scope: { username: '=username', reputation: '=reputation' }, ...
Once Powershell remoting is enabled (Enable-PSRemoting) You can run commands on the remote computer like this: Invoke-Command -ComputerName "RemoteComputerName" -ScriptBlock { Write host "Remote Computer Name: $ENV:ComputerName" } The above method creates a temporary se...
docker-compose run service-name command If, for example, you wanted to run rake db:create in your web service, you'd use the following command: docker-compose run web rake db:create
Install Docker Engine. If you get a Permission denied error, Run sudo -i before the two commands below, then exit. Pull Docker Compose to /usr/local/bin/docker-compose. curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/loc...
TYPO3 can be solely installed with the PHP dependency manager composer. Composer has to be available on the server, then a TYPO3 project can be started by using the base distribution. composer create-project typo3/cms-base-distribution . This will pull the TYPO3 core from the git repository, dow...
OperatorComparisonExample==Equali == 0===Equal Value and Typei === "5"!=Not Equali != 5!==Not Equal Value or Typei !== 5>Greater thani > 5<Less thani < 5>=Greater than or equali >= 5<=Less than or equali <= 5
View components encapsulate reusable pieces of logic and views. They are defined by: A ViewComponent class containing the logic for fetching and preparing the data for the view and deciding which view to render. One or more views Since they contain logic, they are more flexible than partial v...
The default project template creates a partial view _LoginPartial.cshtml which contains a bit of logic for finding out whether the user is logged in or not and find out its user name. Since a view component might be a better fit (as there is logic involved and even 2 services injected) the followin...
Comparison operators compare two values and return to you a boolean (True or False) as the result. Equality The equal sign = is used both for equality comparison and assignment. If leftValue = rightValue Then ... Inequality The left angle bracket nest to the right angle bracket <> p...
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...
Using a subclass of NSThread allows implementation of more complex threads (for example, to allow passing more arguments or to encapsulate all related helper methods in one class). Additionally, the NSThread instance can be saved in a property or variable and can be queried about its current state ...
The #Const directive is used to define a custom preprocessor constant. These can later be used by #If to control which blocks of code get compiled and executed. #Const DEBUGMODE = 1 #If DEBUGMODE Then Const filepath As String = "C:\Users\UserName\Path\To\File.txt" #Else Cons...
If you are optimizing all images manually, disable APT Cruncher for a smaller APK file size. android { aaptOptions { cruncherEnabled = false } }
This is very common, you memorize a path to a file or folder, you open up Vim and try to write what you've just memorized, but you are not 100% sure it's correct, so you close the editor and start over. When you want the path completion feature, and you have a file /home/ubuntu/my_folder/my_file a...
As the Clang front-end is designed for being compatible with GCC, most programs that can be compiled via GCC will compile when you swap g++ by clang++ in the build scripts. If no -std=version is given, gnu11 will be used. Windows users who are used to MSVC can swap cl.exe with clang-cl.exe. By defa...
The widely used combination of tic and toc can provide a rough idea of the execution time of a function or code snippets. For comparing several functions it shouldn't be used. Why? It is almost impossible to provide equal conditions for all code snippets to compare within a script using above solu...
Python 2 includes a cmp function which allows you to determine if one object is less than, equal to, or greater than another object. This function can be used to pick a choice out of a list based on one of those three options. Suppose you need to print 'greater than' if x > y, 'less than' if x &...
When we want to count the number of items in an iterable, that meet some condition, we can use comprehension to produce an idiomatic syntax: # Count the numbers in `range(1000)` that are even and contain the digit `9`: print (sum( 1 for x in range(1000) if x % 2 == 0 and '9' in str...

Page 11 of 34