Tutorial by Examples: c

The idea is to have one or more control machines from where you can issue ad-hoc commands to remote machines (via ansible tool) or run a sequenced instruction set via playbooks (via ansible-playbook tool). Basically, we use Ansible control machine, this will typically be your desktop, laptop or s...
# create a window with a button that closes the window when clicked window = cmds.window(title='example window') # create the window layout = cmds.columnLayout(adjustableColumn=True) # add a vertical layout def close_window(*_): cmds.deleteUI(window) # delet...
Basic printing std::ostream_iterator allows to print contents of an STL container to any output stream without explicit loops. The second argument of std::ostream_iterator constructor sets the delimiter. For example, the following code: std::vector<int> v = {1,2,3,4}; std::copy(v.begin(), v...
The try...catch...finally statement combines exception handling with clean-up code. The finally block contains code that will be executed in all circumstances. This makes them suitable for resource management, and other kinds of cleanup. Try-finally Here is an example of the simpler (try...finally...
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1") .setShortLabel("Web site") // Shortcut Icon tab .setLongLabel("Open the web site") // Displayed When Long Pressing On Ap...

C#

Here's how to close a popup alert in C# with Selenium: IAlert alert = driver.SwitchTo().Alert(); // Prints text and closes alert System.out.println(alert.Text); alert.Accept(); or alert.Dismiss(); according to your needs. Another way you can do this, is wrap your code inside a try-catch: ...
Mage::getSingleton('customer/session')->isLoggedIn()
To create a new model in your module Add a folder Model in your module root folder and create a file Modelname.php in this folder. for example Rick/Demo/Model/Modelname.php The class name of your model does matter call it like this: <?php class Rick_Demo_Model_Modelname { } make sure y...
First we must edit the SSH daemon config file. Though under different Linux distributions this may be located in different directories, usually it is stored under /etc/ssh/sshd_config Use your text editor to change the values set in this file, all lines starting with # are commented out and must ha...
The passport-local module is used to implement a local authentication. This module lets you authenticate using a username and password in your Node.js applications. Registering the user : const passport = require('passport'); const LocalStrategy = require('passport-local').Strategy; // A ...
The passport-facebook module is used to implement a Facebook authentication. In this example, if the user does not exist on sign-in, he is created. Implementing strategy : const passport = require('passport'); const FacebookStrategy = require('passport-facebook').Strategy; // Strategy is name...
Since ls() finds objects by names, it's a handy way to find out if an object is present in the scene. ls() with a list of objects will only return the ones which are in the scene. available_characters = cmds.ls('fred', 'barney', 'wilma', 'dino') # available_characters will contain only the named...
template<class ... Types> struct Tuple {}; A parameter pack is a template parameter accepting zero or more template arguments. If a template has at least one parameter pack is a variadic template.
The pattern parameter_pack ... is expanded into a list of comma-separated substitutions of parameter_pack with each one of its parameters template<class T> // Base of recursion void variadic_printer(T last_argument) { std::cout << last_argument; } template<class T, class .....
Maya commands come in a very small range of forms. Recognizing the form that a command takes is useful for working with new commands. Simple commands The most basic form is simply <command>(<object>) where is the function you're calling and is the string name of an object you are ...
Entity toBeTeleported; //The entity you want to teleport Location teleportTo = new Location(world,x,y,z,yaw,pitch); //The location to teleport to boolean success = toBeTeleported.teleport(teleportTo); if(success) { //Teleport was successful }else { //Teleport wasn't success...
Java's checked exception mechanism requires the programmer to declare that certain methods could throw specifed checked exceptions. This is done using the throws clause. For example: public class OddNumberException extends Exception { // a checked exception } public void checkEven(int number) ...
Install from npm chai, chai-immutable, and ts-node npm install --save-dev chai chai-immutable ts-node Install types for mocha and chai npm install --save-dev @types/mocha @types/chai Write simple test file: import {List, Set} from 'immutable'; import * as chai from 'cha...
MediaTypeFormatter is an abstract class from which JsonMediaTypeFormatter and XmlMediaTypeFormatter classes inherit from. Here, JsonMediaTypeFormatter class handles JSON objects and XmlMediaTypeFormatter class handles XML objects. Return only JSON irrespective of the Accept Header value: To return...
Let's create very simple video player using QtMultimedia module of Qt 5. In .pro file of your application you will need the following lines: QT += multimedia multimediawidgets Note that multimediawidgets is necessary for usage of QVideoWidget. #include <QtMultimedia/QMediaPlayer> #inclu...

Page 629 of 826