Tutorial by Examples: n

When a base class provides a set of overloaded functions, and a derived class adds another overload to the set, this hides all of the overloads provided by the base class. struct HiddenBase { void f(int) { std::cout << "int" << std::endl; } void f(bool) { std::cout &...
Member functions can also be declared virtual. In this case, if called on a pointer or reference to an instance, they will not be accessed directly; rather, they will look up the function in the virtual function table (a list of pointers-to-member-functions for virtual functions, more commonly know...
All non-static member functions have a hidden parameter, a pointer to an instance of the class, named this; this parameter is silently inserted at the beginning of the parameter list, and handled entirely by the compiler. When a member of the class is accessed inside a member function, it is silent...
One of the primary uses for this cv-qualifiers is const correctness. This is the practice of guaranteeing that only accesses that need to modify an object are able to modify the object, and that any (member or non-member) function that doesn't need to modify an object doesn't have write access to t...
configuration EnableIISFeature { node localhost { WindowsFeature IIS { Ensure = “Present” Name = “Web-Server” } } } If you run this configuration in Powershell (EnableIISFeature), it will produce a localho...
Starting a DSC on a remote machine is almost just as simple. Assuming you've already set up Powershell remoting (or enabled WSMAN). $remoteComputer = "myserver.somedomain.com" $cred = (Get-Credential) Start-DSCConfiguration -ServerName $remoteComputer -Credential $cred -Verbose Nb: A...
Sometimes it can be useful to test your Powershell data files and iterate through the nodes and servers. Powershell 5 (WMF5) added this neat little feature for doing this called Import-PowerShellDataFile . Example: $data = Import-PowerShellDataFile -path .\MydataFile.psd1 $data.AllNodes
Before you can use a resource in a configuration, you must explicitly import it. Just having it installed on your computer, will not let you use the resource implicitly. Import a resource by using Import-DscResource . Example showing how to import the PSDesiredStateConfiguration resource and the F...
#!/usr/bin/env python """ An annotated simple socket server example in python. WARNING: This example doesn't show a very important aspect of TCP - TCP doesn't preserve message boundaries. Please refer to http://blog.stephencleary.com/2009/04/message-framing.html before adaptin...
#!/usr/bin/env python """ An annotated simple socket client example in python. WARNING: This example doesn't show a very important aspect of TCP - TCP doesn't preserve message boundaries. Please refer to http://blog.stephencleary.com/2009/04/message-framing.html before adaptin...
Detailed instructions on getting pthreads set up or installed.
Passwords should never be stored as plain text! They should be hashed with a randomly generated salt (to defend against rainbow table attacks) using a slow password hashing algorithm. A high number of iterations (> 10k) can be used to slow down brute force attacks. A delay of ~100ms is acceptable...
Apart from primitives, the Explicit Layout structs (Unions) in C#, can also contain other Structs. As long as a field is a Value type and not a Reference, it can be contained in a Union: using System; using System.Runtime.InteropServices; // The struct needs to be annotated as "Explici...
Signing a script is done by using the Set-AuthenticodeSignature-cmdlet and a code-signing certificate. #Get the first available personal code-signing certificate for the logged on user $cert = @(Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert)[0] #Sign script using certificate Se...
To change the execution policy for the default scope (LocalMachine), use: Set-ExecutionPolicy AllSigned To change the policy for a specific scope, use: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy AllSigned You can suppress the prompts by adding the -Force switch.
Often you might need to execute an unsigned script that doesn't comply with the current execution policy. An easy way to do this is by bypassing the execution policy for that single process. Example: powershell.exe -ExecutionPolicy Bypass -File C:\MyUnsignedScript.ps1 Or you can use the shorthan...
Getting the effective execution policy for the current session: PS> Get-ExecutionPolicy RemoteSigned List all effective execution policies for the current session: PS> Get-ExecutionPolicy -List Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined...
Get information about the Authenticode signature from a signed script by using the Get-AuthenticodeSignature-cmdlet: Get-AuthenticodeSignature .\MyScript.ps1 | Format-List *
When signing personal scripts or when testing code signing it can be useful to create a self-signed code signing certificate. 5.0 Beginning with PowerShell 5.0 you can generate a self-signed code signing certificate by using the New-SelfSignedCertificate-cmdlet: New-SelfSignedCertificate -Friendl...
Dynamic SQL enables us to generate and run SQL statements at run time. Dynamic SQL is needed when our SQL statements contains identifier that may change at different compile times. Simple Example of dynamic SQL: CREATE PROC sp_dynamicSQL @table_name NVARCHAR(20), @col_name NVARCHAR(2...

Page 644 of 1088