Tutorial by Examples: c

This is a unit test of a component that has Store as a dependency. Here, we are creating a new class called MockStore that is injected into our component instead of the usual Store. import { Injectable } from '@angular/core'; import { TestBed, async} from '@angular/core/testing'; import { AppComp...
This is a unit test of a component that has Store as a dependency. Here, we are able to use a store with the default "initial state" while preventing it from actually dispatching actions when store.dispatch() is called. import {TestBed, async} from '@angular/core/testing'; import {AppCom...
While the basic invocation above is easy enough, the curses package provides the wrapper(func, ...) helper function. The example below contains the equivalent of above: main(scr, *args): # -- Perform an action with Screen -- scr.border(0) scr.addstr(5, 5, 'Hello from Curses!', curses...
//By range address worksheet.Cells["A1:B5"].Merge = true; //By indexes worksheet.Cells[1,1,5,2].Merge = true;
Get-ChildItem -Path $PSScriptRoot This example retrieves the list of child items (directories and files) from the folder where the script file resides. The $PSScriptRoot automatic variable is $null if used from outside a PowerShell code file. If used inside a PowerShell script, it automatically ...
[DscResource()] class File { } This example demonstrates how to build the outer section of a PowerShell class, that declares a DSC Resource. You still need to fill in the contents of the class definition.
[DscResource()] class Ticket { [DscProperty(Key)] [string] $TicketId } A DSC Resource must declare at least one key property. The key property is what uniquely identifies the resource from other resources. For example, let's say that you're building a DSC Resource that represents a ticket...
[DscResource()] class Ticket { [DscProperty(Key)] [string] $TicketId [DscProperty(Mandatory)] [string] $Subject } When building a DSC Resource, you'll often find that not every single property should be mandatory. However, there are some core properties that you'll want to ensure ...
[DscResource()] class Ticket { [DscProperty(Key)] [string] $TicketId # The subject line of the ticket [DscProperty(Mandatory)] [string] $Subject # Get / Set if ticket should be open or closed [DscProperty(Mandatory)] [string] $TicketState [void] Set() { # Creat...
@{ RootModule = 'MyCoolModule.psm1' ModuleVersion = '1.0' CompatiblePSEditions = @('Core') GUID = '6b42c995-67da-4139-be79-597a328056cc' Author = 'Bob Schmob' CompanyName = 'My Company' Copyright = '(c) 2017 Administrator. All rights reserved.' Description = 'It does cool stu...
Rather than defining all of your functions in a single .psm1 PowerShell script module file, you might want to break apart your function into individual files. You can then dot-source these files from your script module file, which in essence, treats them as if they were part of the .psm1 file itself...
Register C++ classes in QML At C++ side, imagine we have a class named QmlCppBridge, it implements a method called printHello(). class QmlCppBridge : public QObject { Q_OBJECT public: Q_INVOKABLE static void printHello() { qDebug() << "Hello, QML!"; } }; ...
Create separate files for header and footer(as they are common for all the pages and it does not make sense to make them a part of a single page) Keep common elements(Like Search/Back/Next etc) in separate file(The idea is to remove any kind of duplication and keeping the segregation logical) Fo...
Manage Files and Projects Ctrl+Shift+R : Open Resource (file, folder or project) Ctrl+Shift+S : Save all files Ctrl+W : Close current file Ctrl+Shift+W : Close all files Editor Window F12 : Jump to Editor Window Ctrl+E : Show list of open Editors. Use arro...
For Getting updated or to do something before app goes live to user you can use below method. AppDidFinishLaunching - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Write your code before app launch return YES; } While ...
There are cases when you need to change Display Name of column in a list view e.g. Column Name showing in the view is "IsApprovalNeeded" and you want to appear as "Is Approval Needed?". You can, of course change the display name of a column by changing the column title in list ...
Typically, some files from the Web Application should not be overwritten when performing the deployment (e.g. web.config). This can be accomplished by: 1) Excluding from output - which means setting Build action to None. This is the easiest way, but it might not work for some particular files or fo...
Web deployment offers the option to automatically backup target Web site (not target Web application!) on deployment. This is recommended to allow web application rollback. In order to configure automatic backups, the following steps must be followed: 1) Enable backups Open %programfiles%\IIS\Mic...
@RunWith(RobolectricTestRunner.class) public class MyActivityTest { @Test public void clickingButton_shouldChangeResultsViewText() throws Exception { MyActivity activity = Robolectric.setupActivity(MyActivity.class); Button button = (Button) activity.findViewById(R.id.button); ...
BlackjackHand blackjackHand = new BlackjackHand( new Card('6', SPADES), Arrays.asList(new Card('4', CLUBS), new Card('A', HEARTS))); Moshi moshi = new Moshi.Builder().build(); JsonAdapter<BlackjackHand> jsonAdapter = moshi.adapter(BlackjackHand.class); String json = jsonAdapte...

Page 682 of 826