Tutorial by Examples

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...
To invalidate your old data and restart existing loader you can use restartLoader() method: private void reload() { getLoaderManager().reastartLoader(LOADER_ID, Bundle.EMPTY, this); }
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...
Given a simple sitecore item: Item item; The item itself does not contain it's url. To obtain a url for an item you need to make a call to the static class Sitecore.Links.LinkManager string url = LinkManager.GetItemUrl(item); an overload of this accepts a UrlOptions class: UrlOptions option...

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()
You can load Magento model using the following code: Mage::getModel('modulename/modelname') Example: Mage::getModel('catalog/product') This will load Mage_Catalog_Model_product
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...
Example from www.phptherightway.com <?php interface OutputInterface { public function load(); } class SerializedArrayOutput implements OutputInterface { public function load() { return serialize($arrayOfData); } } class JsonStringOutput implements Output...
Passport must be initialized using passport.initialize() middleware. To use login sessions, passport.session() middleware is required. Note that passport.serialize() and passport.deserializeUser() methods must be defined. Passport will serialize and deserialize user instances to and from the sessi...
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...
GDAL is available in the default repositories of most popular Linux distributions and can be installed in the same way that packages in a Linux distribution are usually installed. apt-get install libgdal-dev CPLUS_INCLUDE_PATH and C_INCLUDE_PATH are necessary in order to include these correspondin...
Official roadmap @ Github VersionAnnouncementsRelease DateRC1*1.0.0-rc12015-11-01RC2*1.0.0-rc22016-05-161.0.01.0.02016-06-271.0.11.0.12016-09-131.0.11.0.12016-09-131.11.1.0Q4 2016 / Q1 20171.21.2.0Q1 2017 / Q2 2017 * References to yearly quarters (Q1, Q2, Q3, Q4) are calendar-based
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 ...
Introduction Consider the following problem: L is a sorted list containing n signed integers (n being big enough), for example [-5, -2, -1, 0, 1, 2, 4] (here, n has a value of 7). If L is known to contain the integer 0, how can you find the index of 0 ? Naïve approach The first thing that comes ...

Page 1011 of 1336