Tutorial by Examples: case

Phantom types are useful for dealing with data, that has identical representations but isn't logically of the same type. A good example is dealing with currencies. If you work with currencies you absolutely never want to e.g. add two amounts of different currencies. What would the result currency o...
Convert in uppercase the string argument Syntax: UPPER(str) UPPER('fOoBar') -- 'FOOBAR' UCASE('fOoBar') -- 'FOOBAR'
In its simplest form supported by all versions of bash, case statement executes the case that matches the pattern. ;; operator breaks after the first match, if any. #!/bin/bash var=1 case $var in 1) echo "Antartica" ;; 2) echo "Brazil" ;; 3) echo "Cat&qu...
4.0 Since bash 4.0, a new operator ;& was introduced which provides fall through mechanism. #!/bin/bash var=1 case $var in 1) echo "Antartica" ;& 2) echo "Brazil" ;& 3) echo "Cat" ;& esac Outputs: Antartica Brazil Cat ...
As the characters/digits can be anywhere within the string, we require lookaheads. Lookaheads are of zero width meaning they do not consume any string. In simple words the position of checking resets to the original position after each condition of lookahead is met. Assumption :- Considering non-wo...
This can be done with a bit of modification in the above regex ^(?=.{10,}$)(?=(?:.*?[A-Z]){2})(?=.*?[a-z])(?=(?:.*?[0-9]){2}).*$ or ^(?=.{10,}$)(?=(?:.*[A-Z]){2})(?=.*[a-z])(?=(?:.*[0-9]){2}).* Let's see how a simple regex ^(?=(?:.*?[A-Z]){2}) works on string abcAdefD Image Credit :- ht...
Capitalize word: M-c Convert word to upper case: M-u Convert word to lower case: M-l
ExecutorService ExecutorService executor = Executors.newFixedThreadPool(50); It is simple and easy to use. It hides low level details of ThreadPoolExecutor. I prefer this one when number of Callable/Runnable tasks are small in number and piling of tasks in unbounded queue does not increase m...
Executors returns different type of ThreadPools catering to specific need. public static ExecutorService newSingleThreadExecutor() Creates an Executor that uses a single worker thread operating off an unbounded queue There is a difference between newFixedThreadPool(1) and newSingleThreadE...
This uses the SwiftyDropbox library to upload a file from a NSFileHandle to the Dropbox account using upload sessions, handling every error case: import UIKit import SwiftyDropbox class ViewController: UIViewController { // filled in later in doUpload: var fileHandle : NSFileHandle?...
Attribute Image capitalizes all characters of enumeration literals. The function Case_Rule_For_Names applies upper case for the first character and makes the rest lower case. with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants; with Ada.Strings.Fixed...
A test case or test script is a more or less formal description of the actions needed to prove that a requirement is met. It has a descriptive title, may start off with some preparation and ends with an expected result. Usually the test cases for a system under test are organised into test suites. ...
Let's pick as an example a function that takes 2 Map and return a Map containing every element in ma and mb: def merge2Maps(ma: Map[String, Int], mb: Map[String, Int]): Map[String, Int] A first attempt could be iterating through the elements of one of the maps using for ((k, v) <- map) and so...
Let's say we have multiple data sources which include database, file, prompt and argumentList. Depending on chosen source we change our approach: def loadData(dataSource: Symbol): Try[String] = dataSource match { case 'database => loadDatabase() // Loading data from database case 'file =&g...
[TestCase(0, 0, 0)] [TestCase(34, 25, 59)] [TestCase(-1250, 10000, 8750)] public void AddNumbersTest(int a, int b, int expected) { // Act int result = a + b; // Assert Assert.That(result, Is.EqualTo(expected)); }
We would be creating mongodb as a replica set having 3 instances. One instance would be primary and the other 2 instances would be secondary. For simplicity, I am going to have a replica set with 3 instances of mongodb running on the same server and thus to achieve this, all three mongodb instances...
[TestCase(0, 0, 0)] [TestCase(34, 25, 59)] [TestCase(-1250, 10000, 8750)] public void AddNumbersTest(int a, int b, int expected) { // Act int result = a + b; // Assert Assert.That(result, Is.EqualTo(expected)); }
The showcase of Primefaces components you can find here and documentation is here Frontend needs to be saved as a XHTML file. This file can contain JSF, JSTL, JSP, HTML, CSS, jQuery, javaScript and its framework and more front-end technologies. Please, do not mix JSF and JSP technologies together....
This is a basic example of a Selenium testcase using the python Unittest library from selenium import webdriver import unittest class SeleniumTest(Unittest.testcase): def setUp(self): self.driver = webdriver.Chrome() self.driver.implicitly_wait(30) def te...
If you want to sort your data numerically or alphabetically, you can simply use order by [column]. If you want to sort using a custom hierarchy, use a case statement. Group ----- Total Young MiddleAge Old Male Female Using a basic order by: Select * from MyTable Order by Group retur...

Page 5 of 8