Tutorial by Examples: is

is

The is macro is the core of the clojure.test library. It returns the value of its body expression, printing an error message if the expression returns a falsey value. (defn square [x] (+ x x)) (require '[clojure.test :as t]) (t/is (= 0 (square 0))) ;;=> true (t/is (= 1 (square 1))) ...
List all the existing remotes associated with this repository: git remote List all the existing remotes associated with this repository in detail including the fetch and push URLs: git remote --verbose or simply git remote -v
The static method Date.now returns the number of milliseconds that have elapsed since 1 January 1970 00:00:00 UTC. To get the number of milliseconds that have elapsed since that time using an instance of a Date object, use its getTime method. // get milliseconds using static method now of Date co...
Equality For basic equality testing, the equal operator == is used. For more comprehensive checks, use the identical operator ===. The identical operator works the same as the equal operator, requiring its operands have the same value, but also requires them to have the same data type. For exampl...
This method will work on modern versions of Arch, CentOS, CoreOS, Debian, Fedora, Mageia, openSUSE, Red Hat Enterprise Linux, SUSE Linux Enterprise Server, Ubuntu, and others. This wide applicability makes it an ideal as a first approach, with fallback to other methods if you need to also identify o...
function isLeapYear(year:int):Boolean { return daysInMonth(year, 1) == 29; }
function isDaylightSavings(d:Date):Boolean { var months:uint = 12; var offset:uint = d.timezoneOffset; var offsetCheck:Number; while (months--) { offsetCheck = (new Date(d.getFullYear(), months, 1)).timezoneOffset; if (offsetCheck != offset) ret...
yii migrate/history # showing the last 10 applied migrations yii migrate/history 5 # showing the last 5 applied migrations yii migrate/history all # showing all applied migrations yii migrate/new # showing the first 10 new migrations yii migrate/new 5 # showing the first 5 ...
yii migrate/mark 150101_185401 # using timestamp to specify the migration yii migrate/mark "2015-01-01 18:54:01" # using a string that can be parsed by strtotime() yii migrate/mark m150101_185401_create_news_table # using full name yii migrate/mark 13...
Let there be Activity B that can be opened, and can further start more Activities. But, user should not encounter it when navigating back in task activities. The simplest solution is to set the attribute noHistory to true for that <activity> tag in AndroidManifest.xml: <activity a...
When the destructor for std::thread is invoked, a call to either join() or detach() must have been made. If a thread has not been joined or detached, then by default std::terminate will be called. Using RAII, this is generally simple enough to accomplish: class thread_joiner { public: thre...
Partial credit to this SO answer. List Concatenation aggregates a column or expression by combining the values into a single string for each group. A string to delimit each value (either blank or a comma when omitted) and the order of the values in the result can be specified. While it is not part ...
The preferred way of describing dependencies is by using constructor injection which follows Explicit Dependencies Principle: ITestService.cs public interface ITestService { int GenerateRandom(); } TestService.cs public class TestService : ITestService { public int GenerateRando...
Builtin container comes with a set of builtin features : Lifetime control public void ConfigureServices(IServiceCollection services) { // ... services.AddTransient<ITestService, TestService>(); // or services.AddScoped<ITestService, TestSer...
With this declaration: fun Temporal.toIsoString(): String = DateTimeFormatter.ISO_INSTANT.format(this) You can now simply: val dateAsString = someInstant.toIsoString()
There are three visibility types that you can apply to methods (class/object functions) and properties (class/object variables) within a class, which provide access control for the method or property to which they are applied. You can read extensively about these in the PHP Documentation for OOP Vi...
Jasmine can spy on an existing function using the spyOn function. let calculator = { multiply: function(a, b) { return a * b; }, square: function(a) { return this.multiply(a, a); } } describe('calculator', function() { it('squares numbers by multiplying them by the...
We can match on lists like any other data type, though they are somewhat unique, in that the constructor for building up lists is the infix function ::. (See the example Creating a list for more on how that works.) matchMyList : List SomeType -> SomeOtherType matchMyList myList = case myL...
The publisher-subscriber is a familiar concept given the rise of YouTube, Facebook and other social media services. The basic concept is that there is a Publisher who generates content and a Subscriber who consumes content. Whenever the Publisher generates content, each Subscriber is notified. Subsc...
A minimal CMake project file that uses Qt5 can be: cmake_minimum_required(VERSION 2.8.11) project(myproject) find_package(Qt5 5.7.0 REQUIRED COMPONENTS Core ) set(CMAKE_AUTOMOC ON) add_executable(${PROJECT_NAME} main.cpp ) target_link_libraries(${PROJECT_NAME} Qt5::C...

Page 19 of 109